/**
 * 项目名：pactera-boot
 * 包名：com.pactera.config.security
 * 文件名：SecurityHelper.java
 * 版本信息：1.0.0
 * 日期：2019年1月14日-下午2:01:26
 * Copyright (c) 2019 Pactera 版权所有
 */
 
package com.pactera.config.security;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.User;

public class SecurityHelper {
	
	public static User getLoginUser(){
		Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
		Object principal = authentication.getPrincipal();
		
		User user = null;
		if(principal!=null){
			user = (User)authentication.getPrincipal();
		}
		return user;
	}

}
